package exemplos.eventos;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;

public class EventSample extends Application {
	Button button;
	TextField tb;
	Label lblNome;
	
	public void start(Stage primaryStage) throws Exception {
		Group root = new Group();
		primaryStage.setResizable(false);
		primaryStage.setScene(new Scene(root, 320,20));
		button = new Button("Ok");
		Label label = new Label("Nome:");
		tb = new TextField();
		lblNome = new Label("...");
		HBox hbox = new HBox(5);

		button.setOnAction(new EventHandler<ActionEvent>() {
		
			@Override
			public void handle(ActionEvent event) {
				lblNome.setText(tb.getText());
		
			}
		
		});
	
//		button.setOnAction(EventHandler<ActionEvent>);
		hbox.getChildren().addAll(label, tb, button, lblNome);
		root.getChildren().add(hbox);
		primaryStage.show();
	}
	public static void main(String[] args) { launch(args); }
}
